#include <dspSimulator/command/breakPoint.h>
#include <dspSimulator/dspSimulator/dspSimulator.h>

void BreakPointCommand::execute(std::string command) {
    auto dspSimulator = dynamic_cast<DSPSimulator *>(m_simulator);
    if (dspSimulator == nullptr) {
        fatalMacro("该模拟器对象不为dsp模拟器对象!");
    }

    if (command.size() < 3) {
        requestReEnter;
        return;
    }
    u32 address = std::stoul(command.substr(2), nullptr, 16);
    dspSimulator->m_breakPoints.insert(address);
}

std::shared_ptr<BreakPointCommand> BreakPointCommand::get(Simulator* dspSimulator) {
    static std::shared_ptr<BreakPointCommand> breakPointCommand;
    if (breakPointCommand == nullptr) {
        breakPointCommand = std::make_shared<BreakPointCommand>(dspSimulator);
    }
    return breakPointCommand;
}
